import qs from 'qs'
import request from '@/utils/request'

// 签名
import _bale from '@/utils/package'
// 获取不同的接口地址
import { uploadApi } from '@/api/index'
import { searchApi } from '@/api/index'

// 获取商品详情
export function getGoodsDetails(params) {
  return request({
    url: '/mallGoods/getGoodsDetails',
    method: 'post',
    data: qs.stringify(_bale('getGoodsDetails', params))
  })
} 
// 商品尺码库存信息
export function getGoodSpec(params) {
  return request({
    url: '/mallGoods/getSupplierInfo',
    method: 'post',
    data: qs.stringify(_bale('getSupplierInfo', params))
  })
}
// 加入购物车
export function addShopCart(params) {
  return request({
    url: '/mallGoods/addShopCart',
    method: 'post',
    data: qs.stringify(_bale('addShopCart', params))
  })
}

// 获取购物车商品列表
export function getCartProductList(params) {
  return request({
    url: '/mallGoods/getShopCart',
    method: 'post',
    data: qs.stringify(_bale('getShopCart', params))
  })
}

// 修改购物车的数量
export function updateProCount(params) {
  return request({
    url: '/mallGoods/updateShopCart',
    method: 'post',
    data: qs.stringify(_bale('updateShopCart', params))
  })
}

// 删除购物车尺码
export function delCartPro(params) {
  return request({
    url: '/mallGoods/deleteShopCart',
    method: 'post',
    data: qs.stringify(_bale('deleteShopCart', params))
  })
}
// 购物车结算验证商品库存
export function validateCartNum(params) {
  return request({
    url: '/mallGoods/validateShopCart',
    method: 'post',
    data: qs.stringify(_bale('deleteShopCart', params))
  })
}
// 设置购物车key
export function submitCartPro(params) {
  return request({
    url: '/mallGoods/setCartKey',
    method: 'post',
    data: qs.stringify(_bale('setCartKey', params))
  })
}

// 确认采购/一件代发 订单
export function getConfirmOrder(params) {
  return request({
    url: '/mallGoods/confirmOrder',
    method: 'post',
    data: qs.stringify(_bale('confirmOrder', params))
  })
}

// 查询用户地址List
export function getAddressList(params) {
  return request({
    url: '/userAddress/seleteUserAddressList',
    method: 'post',
    data: qs.stringify(_bale('seleteUserAddressList', params))
  })
}

// 获取地址详情
export function updateUserAddress(params) {
  return request({
    url: '/userAddress/addUserAddress',
    method: 'post',
    data: qs.stringify(_bale('addUserAddress', params))
  })
}

// 获取地址详情
export function getUserAddress(params) {
  return request({
    url: '/userAddress/selectUserAddress',
    method: 'post',
    data: qs.stringify(_bale('getUserInfo', params))
  })
}
// 删除用户地址
export function delUserAddress(params) {
  return request({
    url: '/userAddress/deleteUserAddress',
    method: 'post',
    data: qs.stringify(_bale('deleteUserAddress', params))
  })
}

// 获取轮播列表
export function getCarouselList(params) {
  return request({
    url: '/index/get_carousel_list' + _bale('get_carousel_list', params, true),
    method: 'get'
  })
}

// 获取供应商货源动态
export function getAppSupplierDynamics(params) {
  return request({
    url: '/app/supplier/getAppSupplierDynamics',
    method: 'post',
    data: qs.stringify(_bale('getAppSupplierDynamics', params))
  })
}

// 获取供应商信息
export function getSupplierInfo(params) {
  return request({
    url: '/supplier/getSupplierInfo',
    method: 'post',
    data: qs.stringify(_bale('getSupplierInfo', params))
  })
}

// 获取供应商商品列表
export function getAppSupplierGoodsList(params) {
  return request({
    url: '/app/supplier/getAppSupplierGoodsList',
    method: 'post',
    data: qs.stringify(_bale('getAppSupplierGoodsList', params))
  })
}

// 查询交易订单
export function getOrderInfo(params) {
  return request({
    url: '/order/getOrderInfo',
    method: 'post',
    data: qs.stringify(_bale('getOrderInfo', params))
  })
}

// 查询交易订单详情
export function getOrderDetails(params) {
  return request({
    url: '/order/getOrderDetails',
    method: 'post',
    data: qs.stringify(_bale('getOrderDetails', params))
  })
}

// 关闭交易订单
export function closeOrder(params) {
  return request({
    url: '/order/closeOrder',
    method: 'post',
    data: qs.stringify(_bale('closeOrder', params))
  })
}

// 删除已关闭订单
export function deleteCloseOrder(params) {
  return request({
    url: '/order/deleteCloseOrder',
    method: 'post',
    data: qs.stringify(_bale('deleteCloseOrder', params))
  })
}

// 确认收货
export function confirmOrder(params) {
  return request({
    url: '/order/confirmOrder',
    method: 'post',
    data: qs.stringify(_bale('confirmOrder', params))
  })
}

// 确认售后商品信息
export function getReturnGoods(params) {
  return request({
    url: '/return/getReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('getReturnGoods', params))
  })
}

// 导入商品库存，接受两个参数file，和params
export function upload(file, params) {
  return request({
    timeout: 180000,
    url: uploadApi + '/upload/img' + _bale('img', params, true),
    method: 'post',
    data: file // file不做签名
  })
}

// 确认售后商品信息
export function applyReturnGoods(params) {
  return request({
    url: '/return/applyReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('applyReturnGoods', params))
  })
}

// 确认售后商品信息
export function getReturnDetails(params) {
  return request({
    url: '/return/getReturnDetails',
    method: 'post',
    data: qs.stringify(_bale('getReturnDetails', params))
  })
}

// 确认售后商品信息
export function revokeReturnGoods(params) {
  return request({
    url: '/return/revokeReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('revokeReturnGoods', params))
  })
}

// 修改已申请售后
export function updateReturnGoods(params) {
  return request({
    url: '/return/updateReturnGoods',
    method: 'post',
    data: qs.stringify(_bale('updateReturnGoods', params))
  })
}

// 查询收藏商品
export function getUserCollect(params) {
  return request({
    url: '/mallGoods/getUserCollect',
    method: 'post',
    data: qs.stringify(_bale('getUserCollect', params))
  })
}

// 商品搜索接口
export function search(params) {
  return request({
    url: 'http://www.sportjx.com/test-web-search' + '/search' + params,
    method: 'get'
  })
}

// 获取品类列表
export function getTypeList(params) {
  return request({
    url: '/app/index/get_type_list' + _bale('get_type_list', params, true),
    method: 'get'
  })
}
// 获取品牌列表
export function getBrandList(params) {
  return request({
    url: '/index/get_brand_list' + _bale('get_brand_list', params, true),
    method: 'get'
  })
}
// 查询索取发票订单列表
export function getAskingInvoice(params) {
  return request({
    url: '/invoice/getAskingInvoice',
    method: 'post',
    data: qs.stringify(_bale('getAskingInvoice', params))
  })
}
// 查看发票模版列表
export function getInvoiceTempList(params) {
  return request({
    url: '/invoice/getInvoiceTempList',
    method: 'post',
    data: qs.stringify(_bale('getInvoiceTempList', params))
  })
}
// 已申请的发票列表
export function invoiceInfoList(params) {
  return request({
    url: '/invoice/invoiceInfoList',
    method: 'post',
    data: qs.stringify(_bale('invoiceInfoList', params))
  })
}
// 跳转索取发票
export function toAddInvoiceInfo(params) {
  return request({
    url: '/invoice/toAddInvoiceInfo',
    method: 'post',
    data: qs.stringify(_bale('toAddInvoiceInfo', params))
  })
}
// 跳转索取发票
export function addEntInvoiceTemp(params) {
  return request({
    url: '/invoice/addEntInvoiceTemp',
    method: 'post',
    data: qs.stringify(_bale('addEntInvoiceTemp', params))
  })
}
// 跳转索取发票
export function addNormalInvoiceTemp(params) {
  return request({
    url: '/invoice/addNormalInvoiceTemp',
    method: 'post',
    data: qs.stringify(_bale('addNormalInvoiceTemp', params))
  })
}
// 跳转索取发票
export function addInvoiceInfo(params) {
  return request({
    url: '/invoice/addInvoiceInfo',
    method: 'post',
    data: qs.stringify(_bale('addInvoiceInfo', params))
  })
}
// 跳转索取发票
export function updateInvoiceTemp(params) {
  return request({
    url: '/invoice/updateInvoiceTemp',
    method: 'post',
    data: qs.stringify(_bale('updateInvoiceTemp', params))
  })
}
// 跳转索取发票
export function getInvoiceTempInfo(params) {
  return request({
    url: '/invoice/getInvoiceTempInfo',
    method: 'post',
    data: qs.stringify(_bale('getInvoiceTempInfo', params))
  })
}

